I'm pretty new to streams in node. I'm trying to listen to the "drain" event when writing to Express.js res stream. The res stream has backpressure and res.write() is returning false as expected. It never emits the 'drain' event. Is Express.js capturing the event and not letting it bubble up?
Example:
function someController(req, res) {
for (let i = 0; i < 1000; i++) {
const flushed = res.write('some text\n')
if (!flushed) {
res.once('drain', () => console.log('drained'))
}
}
res.end()
}